﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CoreData;
using Helper;
using System.Reflection;
using SchoolManagementSystem.Controls;
namespace SchoolManagementSystem.Forms.BusinessForm
{
    //HV dong dư học phí
    public partial class frmStudentOverPay : DevExpress.XtraEditors.XtraForm
    {
        IList<OverPayInfo> datas;
        public frmStudentOverPay()
        {
            InitializeComponent();
            LoadData();
        }



        void LoadData()
        {
            splashScreenManager1.ShowWaitForm();
            datas = RegisterService.RegisterServices.ReceiptVoucherFeeService.GetListStudentPayOverBalance();
            if(datas==null)
                datas=  new List<OverPayInfo>();
            gridControl1.DataSource = datas;
            gridControl1.RefreshDataSource();
            gridView1.ViewCaption = "Danh sách có " + gridView1.RowCount + " dòng";
            gridView1.BestFitColumns();
            PropertyInfo[] propertyInfos;
            propertyInfos = new OverPayInfo().GetType().GetProperties();

            foreach (PropertyInfo proInfo in propertyInfos)
            {
                AttributeCollection attributes = TypeDescriptor.GetProperties(new OverPayInfo().GetType())[proInfo.Name].Attributes;

                DescriptionAttribute myAttribute =
                   (DescriptionAttribute)attributes[typeof(DescriptionAttribute)];
                if (String.IsNullOrEmpty(myAttribute.Description))
                {
                    gridView1.Columns[proInfo.Name].Visible = false;
                }
                else
                {
                    gridView1.Columns[proInfo.Name].Caption = myAttribute.Description;
                    gridView1.Columns[proInfo.Name].OptionsColumn.AllowEdit = false;
                }
                SetFormatGridColumn.Format(null, gridView1, proInfo.Name);
            }
            splashScreenManager1.CloseWaitForm();

        }

        private void cmdRefresh_Click(object sender, EventArgs e)
        {
            LoadData();
        }

    }
}
